﻿<%@ Page Title="Strategic Asset Management Las Vegas: Escrow" Language="C#" MasterPageFile="~/Site2.Master" AutoEventWireup="true"
    CodeBehind="EscrowList.aspx.cs" Inherits="LenderClearingHouse.EscrowList" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="ListFilterControl.ascx" TagName="ListFilterControl" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphPageHeader" runat="server">
    Escrow
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMain" runat="server">
  <telerik:RadWindowManager runat="server" Behavior="Default" InitialBehavior="None"
        ID="RadWindowManager1" Modal="True" Behaviors="Resize, Close, Move" ReloadOnShow="True"
        ShowContentDuringLoad="False" VisibleStatusbar="False" VisibleTitlebar="True"
        Width="500px" Title="NET SHEET">
  </telerik:RadWindowManager>

      <script type="text/javascript">
        function OpenNetSheetDialog() {
          //var pprice = $('#' + ctrlName + '_display').html();
          var pprice = $('#div-buyer-purchase-price-value').html();
          if (!pprice)
            pprice = 0;
          
          OpenNetSheetDialogByPrice(pprice);
        }

        function OpenNetSheetDialogByPrice(pprice, rehabCosts, propertyId) {
            if (!rehabCosts) rehabCosts = $('#div-rehabcosts-value').html();

            if (!propertyId) propertyId = $('#div-propertyid').html();
            if (!propertyId) {
                alert('Unknown property id!')
                return;
            }

            var oWnd = radopen("NetSheetDialog.aspx?BuyerPurchasePrice=" + encodeURIComponent(pprice) + "&RehabCosts=" + encodeURIComponent(rehabCosts) + "&PropertyId=" + encodeURIComponent(propertyId), "RadWindow1");
          oWnd.setSize(800, 700);
          oWnd.Center();
          return false;
        }

        function SetNetProfit(netProfit, buyerPurchasePrice, buyerPurchasePriceValue, rehabCosts, rehabCostsValue, purchasePrice, purchasePriceValue) {
              $('#div-net-profit').html(netProfit);
              $('#div-buyer-purchase-price').html(buyerPurchasePrice);
              $('#div-buyer-purchase-price-value').html(buyerPurchasePriceValue);
              $('#div-purchase-price').html(purchasePrice);
              $('#div-purchase-price-value').html(purchasePriceValue);
              $('#div-rehabcosts-value').html(rehabCostsValue);
          }
      </script>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="grid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grid" UpdatePanelHeight="" />
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" UpdatePanelHeight="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnection %>"
            OnSelecting="SqlDataSource_Selecting" SelectCommand="getLvreo_MasterListEscrow"
            SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter ConvertEmptyStringToNull="False" Name="Apn" Type="String" />
                <asp:Parameter ConvertEmptyStringToNull="False" Name="PropLocation" Type="String" />
                <asp:Parameter ConvertEmptyStringToNull="False" Name="Zip" Type="String" />
                <asp:Parameter ConvertEmptyStringToNull="False" Name="archive" Type="Boolean" />
            </SelectParameters>
        </asp:SqlDataSource>
            <fieldset>
    <legend>Parameters</legend>
        &nbsp;&nbsp;Days&nbsp;Variable:&nbsp;<asp:TextBox ID="tb10daysVariable" runat="server" ValidationGroup="percents"></asp:TextBox>&nbsp;&nbsp;
        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" ValidationGroup="percents" />
        <br />
        <br />
        
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%">
          &nbsp;&nbsp;Property&nbsp;Location:&nbsp;
          <telerik:RadComboBox
            ID="cbProperty" runat="server" Width="350" EmptyMessage="Type a Property Location" 
            AllowCustomText="true" MarkFirstMatch="true" AutoPostBack="true"
            DataSourceID="SqlDataSourcePropertyCombo" DataTextField="PropertyLocation" DataValueField="PropertyId" 
            OnSelectedIndexChanged="cbProperty_SelectedIndexChanged">
          </telerik:RadComboBox>
          <asp:SqlDataSource ID="SqlDataSourcePropertyCombo" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnection %>"
                   SelectCommand="getPropertyCombo" SelectCommandType="StoredProcedure" />
          <asp:Button runat="server" ID="btnShowNetSheet" Text="Net Sheet" Enabled="false" />
        </telerik:RadAjaxPanel>
        <br />
    </fieldset>
    <br />

    <uc1:ListFilterControl ID="listFilter" runat="server" />
    <div class="panel5">
        <table width="940" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="122" height="32" valign="middle">
                    &nbsp;
                </td>
                <td width="40" valign="middle">
                    <img src="images/excel_icon.png" width="30" height="30" />
                </td>
                <td width="137" valign="middle">
                    <asp:LinkButton ID="lnkExportToExcel" CssClass="link1" runat="server" 
                        Text="Escrow Report" onclick="lnkExportToExcel_Click"></asp:LinkButton>
                </td>
                <!--<td width="40" valign="middle">
                    <img src="images/excel_icon.png" width="30" height="30" />
                </td>
                <td width="137" valign="middle">
                    <asp:LinkButton ID="lnkBackendReport" CssClass="link1" runat="server" 
                        Text="Back end report" onclick="lnkBackendReport_Click"></asp:LinkButton>
                </td>-->
                <td width="40" valign="middle">
                    <img src="images/refresh_icon.png" width="30" height="30" />
                </td>
                <td width="118" valign="middle">
                    <asp:LinkButton ID="lnkArchive" CssClass="link1" runat="server" 
                        Text="Archive" onclick="LinkButton1_Click"></asp:LinkButton>&nbsp;
                </td>
                <td width="40" valign="middle">
                    <img src="images/refresh_icon.png" width="30" height="30" />
                </td>
                <td width="118" valign="middle">
                    <asp:LinkButton ID="lnkRefreshGrid" CssClass="link1" runat="server" 
                        Text="Refresh Grid" onclick="lnkRefreshGrid_Click"></asp:LinkButton>&nbsp;
                </td>
                <td width="*">
                    &nbsp;
                </td>
            </tr>
        </table>
    </div>
    <!--Panel Five: "Export & etc..." Ends-->

    <br />
    <div class="panel7">
        <telerik:RadGrid ID="grid" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource" Width="1160px"
            AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" 
            PageSize="10" ShowFooter="True" ShowStatusBar="True" 
            onupdatecommand="grid_UpdateCommand" onitemdatabound="grid_ItemDataBound" OnItemCreated="grid_ItemCreated"
           OnItemEvent="Grid_ItemEvent" onpageindexchanged="grid_PageIndexChanged" onpagesizechanged="grid_PageSizeChanged"
           SortCommand="grid_SortCommand" PageIndexChanged="grid_PageIndexChanged">
            <GroupingSettings CaseSensitive="False" />
            <ClientSettings>
                <Scrolling ScrollHeight="500px" AllowScroll="True" UseStaticHeaders="True" FrozenColumnsCount="2" />
            </ClientSettings>
            <MasterTableView DataSourceID="SqlDataSource" Width="100%" DataKeyNames="PropertyId">
                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton">
                    </telerik:GridEditCommandColumn>
                    
                    <telerik:GridHyperLinkColumn 
                        DataTextField="PropertyLocation" HeaderText="Address" 
                        UniqueName = "Address" SortExpression = "PropertyLocation"
                        DataNavigateUrlFormatString="~/PropertyDetails2.aspx?propertyId={0}"
                        DataNavigateUrlFields="PropertyId">
                    </telerik:GridHyperLinkColumn>

                    <telerik:GridBoundColumn DataField="PurchaseAgreementReceived" DataType="System.DateTime"
                        HeaderText="Purchase Agreement Received" SortExpression="PurchaseAgreementReceived"
                        UniqueName="PurchaseAgreementReceived" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CAP" 
                        HeaderText="CAP" SortExpression="CAP"
                        DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                        UniqueName="CAP">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="DateAccept" 
                        HeaderText="Accept Date" SortExpression="DateAccept"
                        DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                        UniqueName="DateAccept">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Apn" HeaderText="Apn" SortExpression="Apn" UniqueName="Apn">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ZipCode" HeaderText="Zip" SortExpression="ZipCode"
                        UniqueName="ZipCode">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="InvestorName" HeaderText="Investor" ReadOnly="True"
                        SortExpression="InvestorName" UniqueName="InvestorName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="TitleCompanyFront" HeaderText="Title Company Front"
                        SortExpression="TitleCompanyFront" UniqueName="TitleCompanyFront">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Loan" HeaderText="Loan" SortExpression="Loan"
                        UniqueName="Loan">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LoanInfo" HeaderText="Loan Info" SortExpression="LoanInfo"
                        UniqueName="LoanInfo">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="EffectiveDateBank" DataType="System.DateTime"
                        HeaderText="Effective Date Bank" SortExpression="EffectiveDateBank" 
                        UniqueName="EffectiveDateBank" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ECOE_F" DataType="System.DateTime" HeaderText="ECOE - F"
                        SortExpression="ECOE_F" UniqueName="ECOE_F" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="AdjPurchasePrice" DataType="System.Int32" HeaderText="Adj Purchase Price"
                        SortExpression="AdjPurchasePrice" UniqueName="AdjPurchasePrice" 
                        DataFormatString="{0:c}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="RECORDED_F" DataType="System.DateTime" HeaderText="RECORDED - F"
                        SortExpression="RECORDED_F" UniqueName="RECORDED_F" 
                        DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CommentsFront" HeaderText="Comments Front" SortExpression="CommentsFront"
                        UniqueName="CommentsFront">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ListingAgreement" DataType="System.DateTime"
                        HeaderText="Listing Agreement" SortExpression="ListingAgreement" 
                        UniqueName="ListingAgreement" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ContractDate" DataType="System.DateTime" HeaderText="Contract Date"
                        SortExpression="ContractDate" UniqueName="ContractDate" 
                        DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ECOE_B" DataType="System.DateTime" HeaderText="ECOE - B"
                        SortExpression="ECOE_B" UniqueName="ECOE_B" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Recorded_B" DataType="System.DateTime" HeaderText="Recorded - B"
                        SortExpression="Recorded_B" UniqueName="Recorded_B" 
                        DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="BuyerPurchasePrice" DataType="System.Int32" HeaderText="Selling Price"
                        SortExpression="BuyerPurchasePrice" UniqueName="BuyerPurchasePrice" 
                        DataFormatString="{0:c}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PurchasePrice" DataType="System.Int32" HeaderText="Purchase Price"
                        SortExpression="PurchasePrice" UniqueName="PurchasePrice" 
                        DataFormatString="{0:c}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PurchaseType" HeaderText="Purchase Type" SortExpression="PurchaseType"
                        UniqueName="PurchaseType">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Incentive" HeaderText="Incentive" SortExpression="Incentive"
                        UniqueName="Incentive">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="HOAManagement" HeaderText="HOA &amp; Management"
                        SortExpression="HOAManagement" UniqueName="HOAManagement">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="MonthlyHOADues" DataType="System.Int32" HeaderText="Monthly HOA Dues"
                        SortExpression="MonthlyHOADues" UniqueName="MonthlyHOADues" 
                        DataFormatString="{0:c}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PastDueHOA" HeaderText="Past due HOA" SortExpression="PastDueHOA"
                        UniqueName="PastDueHOA">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ResalePacketOrdered" DataType="System.DateTime"
                        HeaderText="Resale Packet Ordered" SortExpression="ResalePacketOrdered" 
                        UniqueName="ResalePacketOrdered" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ResalePkgToAgent" HeaderText="Resale Pkg to Agent"
                        SortExpression="ResalePkgToAgent" UniqueName="ResalePkgToAgent">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="TitleCompanyBack" HeaderText="Title Company Back"
                        SortExpression="TitleCompanyBack" UniqueName="TitleCompanyBack">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="BuyerName" HeaderText="Buyer's Name" SortExpression="BuyerName"
                        UniqueName="BuyerName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="COOPAgent" HeaderText="COOP Agent" SortExpression="COOPAgent"
                        UniqueName="COOPAgent">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Lender" HeaderText="Lender" SortExpression="Lender"
                        UniqueName="Lender">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="WalkThrough" DataType="System.DateTime" HeaderText="Walk Through"
                        SortExpression="WalkThrough" UniqueName="WalkThrough" 
                        DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="DocsIn" DataType="System.DateTime" HeaderText="Doc's In"
                        SortExpression="DocsIn" UniqueName="DocsIn" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="SellerSign" DataType="System.DateTime" HeaderText="Seller Sign"
                        SortExpression="SellerSign" UniqueName="SellerSign" 
                        DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="BuyerSign" DataType="System.DateTime" HeaderText="Buyer Sign"
                        SortExpression="BuyerSign" UniqueName="BuyerSign" DataFormatString="{0:MM/dd/yyyy}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CommentsBack" HeaderText="Comments Back" SortExpression="CommentsBack"
                        UniqueName="CommentsBack">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PropertyId" DataType="System.Int64" HeaderText="PropertyId"
                        SortExpression="PropertyId" UniqueName="PropertyId" Visible="False">
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings EditFormType="WebUserControl" UserControlName="EscrowEditControl.ascx">
                    <EditColumn UniqueName="EditCommandColumn1">
                    </EditColumn>
                </EditFormSettings>
                <PagerStyle AlwaysVisible="True" />
            </MasterTableView>
            <PagerStyle AlwaysVisible="True" />
        </telerik:RadGrid>
    </div>
</asp:Content>
